package com.biboheart.adapter.adapter;

import com.biboheart.adapter.adapter.impl.DefaultConverter;
import com.biboheart.adapter.support.exception.ConvertException;

public class ConverterBuilder {
    private static volatile Converter sharedInstance;

    public static Converter getSharedInstance() {
        Converter converter = sharedInstance;
        if (null == converter) {
            synchronized (ConverterBuilder.class) {
                converter = sharedInstance;
                if (converter == null) {
                    converter = new DefaultConverter();
                    sharedInstance = converter;
                }
            }
        }
        return converter;
    }

    public static <T> T conversion(Object input, String describe, Class<T> clazz) throws ConvertException {
        return ConverterBuilder.getSharedInstance().conversion(input, describe, clazz);
    }
}
